/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rh.game.impl;

import com.rh.game.Character;
import com.rh.game.GameEffect;
import com.rh.game.GameObject;
import com.rh.game.Location;

/**
 *
 * @author Hayden
 */
public class GameEffect1 implements GameEffect {
    public static GameEffect GAME_OVER = new GameEffect1(Type.GAME_OVER, GameObject.NULL, Character.NULL, Location.NULL);
    
    GameEffect1(Type pType, GameObject pObject, Character pWhom, Location pLocation)  {
        this(pType, pObject, pWhom, pLocation, null);
    }
    
    public GameEffect1(Type pType, GameObject pObject, Character pWhom, Location pLocation, Character pWhom2)  {
        super();
        type = pType;
        object = pObject;
        character = pWhom;
        character2 = pWhom2;
        location = pLocation;
    }
    
    public static GameEffect m2f()  {
        return new GameEffect1(Type.MALE_TO_FEMALE, GameObject.NULL, Character.WEARER, Location.NULL);
    }
    
    public static GameEffect m2f(Character pWhom)  {
        return new GameEffect1(Type.MALE_TO_FEMALE, GameObject.NULL, pWhom, Location.NULL);
    }
    
    public static GameEffect f2m(Character pWhom)  {
        return new GameEffect1(Type.FEMALE_TO_MALE, GameObject.NULL, pWhom, Location.NULL);
    }
    
    static GameEffect addInventory(GameObject pObject, Character pWhom)  {
        return new GameEffect1(Type.INVENTORY_ADD, pObject, pWhom, Location.NULL);
    }
    
    static GameEffect removeInventory(GameObject pObject, Character pWhom)  {
        return new GameEffect1(Type.INVENTORY_REMOVE, pObject, pWhom, Location.NULL);
    }

    static GameEffect removeWearing(GameObject pObject, Character pWhom)  {
        return new GameEffect1(Type.WEARING_REMOVE, pObject, pWhom, Location.NULL);
    }

    static GameEffect genderSwap(Character c1, Character c2)  {
        return new GameEffect1(Type.GENDER_SWAP, GameObject.NULL, c1, Location.NULL, c2);
    }
    public static GameEffect wearer(GameEffect ge, Character whom)  {
        if (ge.getCharacter() != Character.WEARER)  return ge;
        return new GameEffect1(
            ge.getType(),
            ge.getObject(),
            whom,
            ge.getLocation());
    }
    
    public static GameEffect move(Character whom, String key)  {
        int dx = 0;
        int dy = 0;

        if (key == null)  key = "";
        key = key.toUpperCase();
        
        if (key.equals("UP"))  {
            dy = -1;
        }
        if (key.equals("LEFT"))  {
            dx = -1;
        }
        if (key.equals("RIGHT"))  {
            dx = 1;
        }
        if (key.equals("DOWN"))  {
            dy = 1;
        }

        Location l = new Location1(whom.getLocation().getID(), whom.getLocation().getX() + dx, whom.getLocation().getY() + dy);
        return stepCharacter(whom, l);
    }
    
    static GameEffect stepCharacter(Character pWhom, Location pWhere)  {
        return new GameEffect1(Type.PLAYER_STEP, GameObject.NULL, pWhom, pWhere);
    }
    
    static GameEffect moveCharacter(Character pWhom, Location pWhere)  {
        return new GameEffect1(Type.MOVE_CHARACTER, GameObject.NULL, pWhom, pWhere);
    }
    
    private Location location = Location.NULL;
    public Location getLocation()  {
        return location;
    }
    
    private Type type = null;
    public Type getType() {
        return type;
    }

    private GameObject object = null;
    public GameObject getObject() {
        return object;
    }

    private Character character = null;
    public Character getCharacter() {
        return character;
    }

    private Character character2 = null;
    public Character getCharacter2() {
        return character2;
    }

    private String chapterID = "";
    public String getChapterID()  {
        return chapterID;
    }
    
    @Override
    public String toString()  {
        return getType() + ", " + getObject() + ", " + getCharacter();
    }
}
